package Authentification;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;

/**
 * Servlet implementation class Client
 */
public class Client extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Client() {
        super();
        // TODO Auto-generated constructor stub
    }


    	private Hashtable users = new Hashtable();
    	public void init(ServletConfig config) throws ServletException {
    	users.put("mickael:baron","allowed");
    	}

    	public void doPost(HttpServletRequest req, HttpServletResponse res)
    	throws ServletException, IOException {
    	res.setContentType("text/html");
    	PrintWriter out = res.getWriter();
    	String account = req.getParameter("login");
    	String password = req.getParameter("password");
    	if (!allowUser(account, password)) {
    	out.println("<HTML><HEAD><TITLE>Access Denied</TITLE></HEAD>");
    	out.println("<BODY>Votre compte et mot de passe sont incorrects.<BR>");
    	out.println("<A HREF=\"/SecuritePersoFormServlet/login.html\">
    	Retenter</A>");
    	out.println("</BODY></HTML>");
    	} else {
    	req.getSession().setAttribute("logon.isDone", account);
    	out.println("Bravo : " + account)
}
    	}
    	}